using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Diagnostics;
using System.Drawing.Drawing2D;

namespace BPMN.MainWindow
{

    public abstract class EventIntermediate : Event
    {

        public EventIntermediate()
            : base()
        {
        }
        public EventIntermediate(PointF location, SizeF size)
            : base(location, size)
        {
        }

        public EventIntermediate(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);
            graphics.DrawEllipse(pen, BoundingBox.Location.X + offset.X, BoundingBox.Location.Y + offset.Y, Size.Width, Size.Height);
            graphics.DrawEllipse(pen, BoundingBox.Location.X + offset.X+Size.Width/8, BoundingBox.Location.Y + offset.Y+Size.Height/8, 6*Size.Width/8, 6*Size.Height/8);

        }
    }
    public class EventIntermediateNone : EventIntermediate
    {
        public EventIntermediateNone()
            : base()
        {
        }
        public EventIntermediateNone(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventIntermediateNone(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);
        }
    }
    public class EventIntermediateMessage : EventIntermediate
    {
        public EventIntermediateMessage()
            : base()
        {
        }
        public EventIntermediateMessage(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventIntermediateMessage(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);
            graphics.DrawRectangle(pen, Location.X + offset.X - (int)Size.Width / 4, Location.Y + offset.Y - (int)Size.Height / 4, Size.Width / 2, Size.Width / 2);
            graphics.DrawLine(pen, Location.X + offset.X - Size.Width / 4, Location.Y + offset.Y - Size.Height / 4, Location.X + offset.X, Location.Y + offset.Y);
            graphics.DrawLine(pen, Location.X + offset.X + Size.Width / 4, Location.Y + offset.Y - Size.Height / 4, Location.X + offset.X, Location.Y + offset.Y);
          // graphics.DrawRectangle(pen, BoundingBox.Location.X + offset.X + 8, BoundingBox.Location.Y + offset.Y + 8, Size.Width - 16, Size.Height - 16);
           // graphics.DrawLine(pen, BoundingBox.Location.X + offset.X + 8, BoundingBox.Location.Y + offset.Y + 8, BoundingBox.Location.X + offset.X + Size.Width / 2, BoundingBox.Location.Y + offset.Y + Size.Height / 2);
           // graphics.DrawLine(pen, BoundingBox.Location.X + offset.X + Size.Width / 2, BoundingBox.Location.Y + offset.Y + Size.Height / 2, BoundingBox.Location.X + offset.X - 8 + Size.Width, BoundingBox.Location.Y + offset.Y + 8);
        }
    }
    public class EventIntermediateTimer : EventIntermediate
    {
        public EventIntermediateTimer()
            : base()
        {
        }
        public EventIntermediateTimer(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventIntermediateTimer(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            
           base.Draw(graphics, pen, brush, offset);
           graphics.DrawEllipse(pen, Location.X + offset.X - (int)Size.Width / 4, Location.Y + offset.Y - (int)Size.Height / 4, Size.Width / 2, Size.Height / 2);
           graphics.DrawLine(pen, Location.X + offset.X, Location.Y + offset.Y, Location.X + offset.X + Size.Width / 5, Location.Y + offset.Y);
           graphics.DrawLine(pen, Location.X + offset.X, Location.Y + offset.Y, Location.X + offset.X + Size.Width / 5 - Size.Width / 10, Location.Y + offset.Y - Size.Height / 6);
           GraphicsPath gp = new GraphicsPath();
           gp.AddLine(BoundingBox.Location.X + offset.X + Size.Width / 2, Location.Y + offset.Y - (int)Size.Height / 4, BoundingBox.Location.X + offset.X + Size.Width / 2, Location.Y + offset.Y - (int)Size.Height / 4 + Size.Height / 13);
            // save a copy of the graphics path so we can reset
            // each time we rotate it.
            GraphicsPath gpOld = new GraphicsPath();
            gpOld = (GraphicsPath)gp.Clone();
            Matrix RotationTransform = new Matrix(1, 0, 0, 1, 0, 0); // rotation matrix
            Matrix TranslationTransform = new Matrix(1, 0, 0, 1, 0, 0); // translation matrix
            //g.DrawEllipse(p,70,70,80,80);
            PointF TheRotationPoint = new PointF(Location.X + offset.X, Location.Y + offset.Y); // rotation point
            for (float f = 0.0f; f < 359.0; f += (float)30.0)
            {
                 gp.Transform(TranslationTransform);
                 RotationTransform.RotateAt(f, TheRotationPoint);
                 gp.Transform(RotationTransform);
                 graphics.FillPath(Brushes.Red, gp);
                 graphics.DrawPath(pen, gp);
                  // reset the transformation matrix
                  RotationTransform.Dispose();
                  RotationTransform = new Matrix(1, 0, 0, 1, 0, 0);
                  // get the original graphics path for our rotation and translation reference
                    gp = (GraphicsPath)gpOld.Clone();
                
            } 
        }
        
    }
    public class EventIntermediateError : EventIntermediate
    {
        public EventIntermediateError()
            : base()
        {
        }
        public EventIntermediateError(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventIntermediateError(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);
            /*GraphicsPath gp = new GraphicsPath();
            gp.AddRectangle(new Rectangle((int)(Location.X + offset.X - Size.Width / 10), (int)(Location.Y + offset.Y - Size.Height / 10), (int)(Size.Width / 6 + offset.X), (int)(Size.Height / 3 + offset.Y)));
            
            GraphicsPath gpOld = new GraphicsPath();
            gpOld = (GraphicsPath)gp.Clone();
            Matrix RotationTransform = new Matrix(1, 0, 0, 1, 0, 0); // rotation matrix
            Matrix TranslationTransform = new Matrix(1, 0, 0, 1, 0, 0); // translation matrix
          
            PointF TheRotationPoint = new PointF(Location.X, Location.Y); // rotation point
            gp.Transform(TranslationTransform);
            RotationTransform.RotateAt(315, TheRotationPoint);
            gp.Transform(RotationTransform);
           // graphics.FillPath(Variables.DrawingBrush, gp);
            //graphics.DrawPath(pen, gp);
            // reset the transformation matrix
            RotationTransform.Dispose();
            RotationTransform = new Matrix(1, 0, 0, 1, 0, 0);
            // get the original graphics path for our rotation and translation reference
            gp.Dispose();*/
            GraphicsPath gp = new GraphicsPath();
            PointF[] points = new PointF[4];
            points[0] = new PointF(Location.X + offset.X - Size.Width / 8, Location.Y + offset.Y - Size.Height/10);
            points[1] = new PointF(Location.X + offset.X - Size.Width / 10, Location.Y + offset.Y + Size.Height/10);
            points[2] = new PointF(Location.X + offset.X + Size.Width / 10, Location.Y + offset.Y - Size.Height/10);
            points[3] = new PointF(Location.X + offset.X + Size.Width / 8, Location.Y + offset.Y + Size.Height / 10);
            gp.AddLines(points);
            Pen p = new Pen(Variables.DrawingBrush,Size.Width/14);
            graphics.DrawPath(p, gp);

        }
    }
    public class EventIntermediateCancel : EventIntermediate
    {
        public EventIntermediateCancel()
            : base()
        {
        }
        public EventIntermediateCancel(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventIntermediateCancel(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);
            Pen p = new Pen(Variables.DrawingBrush, Size.Width / 8);
            graphics.DrawLine(p,Location.X + offset.X - Size.Width / 5, Location.Y + offset.Y - Size.Height / 5, Location.X + offset.X + Size.Width / 5, Location.Y + offset.Y + Size.Height / 5);
            graphics.DrawLine(p,Location.X + offset.X - Size.Width / 5, Location.Y + offset.Y + Size.Height / 5, Location.X + offset.X + Size.Width / 5, Location.Y + offset.Y - Size.Height / 5);
        }
    }
    public class EventIntermediateCompensation : EventIntermediate
    {
        public EventIntermediateCompensation()
            : base()
        {
        }
        public EventIntermediateCompensation(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventIntermediateCompensation(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);
            GraphicsPath gp = new GraphicsPath();
            PointF []points=new PointF[4];
            points[0]=new PointF(Location.X+offset.X ,Location.Y+offset.Y);
            points[2] = new PointF(Location.X + offset.X+Size.Width/4, Location.Y + offset.Y-Size.Height/4);
            points[3] = new PointF(Location.X + offset.X, Location.Y + offset.Y);
            points[1] = new PointF(Location.X + offset.X + Size.Width / 4, Location.Y + offset.Y+Size.Height/4);
            gp.AddLines(points);
            PointF[] points2 = new PointF[4];
            points2[0] = new PointF(Location.X + offset.X-Size.Width/3, Location.Y + offset.Y);
            points2[2] = new PointF(Location.X + offset.X  , Location.Y + offset.Y - Size.Height / 4);
            points2[3] = new PointF(Location.X + offset.X - Size.Width/3 , Location.Y + offset.Y);
            points2[1] = new PointF(Location.X + offset.X , Location.Y + offset.Y + Size.Height / 4);
            gp.AddLines(points2);
            graphics.FillPath(Variables.DrawingBrush, gp);
        }
    }
    public class EventIntermediateLink : EventIntermediate
    {
        public EventIntermediateLink()
            : base()
        {
        }
        public EventIntermediateLink(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventIntermediateLink(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {

            base.Draw(graphics, pen, brush, offset);
            GraphicsPath gp = new GraphicsPath();
            PointF[] points = new PointF[4];
            points[0] = new PointF(Location.X + offset.X + Size.Width / 3, Location.Y + offset.Y);
            points[1] = new PointF(Location.X + offset.X + Size.Width / 10, Location.Y + offset.Y + Size.Height / 3);
            points[2] = new PointF(Location.X + offset.X + Size.Width / 10, Location.Y + offset.Y - Size.Height / 3);
            points[3] = new PointF(Location.X + offset.X + Size.Width / 3, Location.Y + offset.Y);
            gp.AddLines(points);
            graphics.FillPath(Variables.DrawingBrush, gp);
            graphics.FillRectangle(Variables.DrawingBrush, Location.X + offset.X - Size.Width / 3, Location.Y + offset.Y - Size.Height / 8, 2 * Size.Width / 5, Size.Height / 4);

        }
    }
    public class EventIntermediateMultiple : EventIntermediate
    {
        public EventIntermediateMultiple()
            : base()
        {
        }
        public EventIntermediateMultiple(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventIntermediateMultiple(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);
            GraphicsPath gp = new GraphicsPath();
            PointF[] points = new PointF[4];
            points[0] = new PointF(Location.X + offset.X, Location.Y + offset.Y - Size.Height / (float)2.8);
            points[1] = new PointF(Location.X + offset.X + Size.Width / 3, Location.Y + offset.Y + Size.Height / 6);
            points[2] = new PointF(Location.X + offset.X - Size.Width / 3, Location.Y + offset.Y + Size.Height / 6);
            points[3] = new PointF(Location.X + offset.X, Location.Y + offset.Y - Size.Height / (float)2.8);
            gp.AddLines(points);
            graphics.FillPath(Variables.DrawingBrush, gp);
            GraphicsPath gp2 = new GraphicsPath();
            PointF[] points2 = new PointF[4];
            points2[0] = new PointF(Location.X + offset.X, Location.Y + offset.Y + Size.Height / (float)2.8);
            points2[1] = new PointF(Location.X + offset.X + Size.Width / 3, Location.Y + offset.Y - Size.Height / 6);
            points2[2] = new PointF(Location.X + offset.X - Size.Width / 3, Location.Y + offset.Y - Size.Height / 6);
            points2[3] = new PointF(Location.X + offset.X, Location.Y + offset.Y + Size.Height / (float)2.8);
            gp2.AddLines(points2);
            graphics.FillPath(Variables.DrawingBrush, gp2);
        }
    }
    public class EventIntermediateRule : EventIntermediate
    {
        public EventIntermediateRule()
            : base()
        {
        }
        public EventIntermediateRule(PointF location, SizeF size)
            : base(location, size)
        {
        }
        [Constructor]
        public EventIntermediateRule(PointF location, SizeF size, FigureState state)
            : base(location, size, state)
        {
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
            base.Draw(graphics, pen, brush, offset);
            graphics.DrawRectangle(pen, Location.X + offset.X - Size.Width / 4, Location.Y + offset.Y - Size.Height / 4, Size.Width / 2, Size.Height / 2);
            graphics.DrawLine(pen, Location.X + offset.X - Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + Size.Height / 8, Location.X + offset.X + Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + Size.Height / 8);
            graphics.DrawLine(pen, Location.X + offset.X - Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + 2 * Size.Height / 8, Location.X + offset.X + Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + 2 * Size.Height / 8);
            graphics.DrawLine(pen, Location.X + offset.X - Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + 3 * Size.Height / 8, Location.X + offset.X + Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + 3 * Size.Height / 8);
            graphics.DrawLine(pen, Location.X + offset.X - Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + 4 * Size.Height / 8, Location.X + offset.X + Size.Width / 7, Location.Y + offset.Y - Size.Height / 4 + 4 * Size.Height / 8);

        }
    }
}

           